/**
 * Alipay.com Inc. Copyright (c) 2004-2018 All Rights Reserved.
 */
package com.alibaba.gov.api.domain;

import com.alibaba.gov.api.exception.AtgBusErrorCode;
import com.alibaba.gov.api.internal.util.Asserts;

/**
 * 政务总线秘钥  SECRET正则表达式错误 重写该类
 * @author fangs
 */
public class AtgBusSecretKey {
    /**秘钥ID*/
    private String keyId;

    /** 秘钥 */
    private String secretKey;

    /** KEY正则表达式 */
    private static String KEY_REGEX = "^[a-z0-9]{32}$";

    /** SECRET正则表达式 */
    private static String SECRET_REGEX = "^.{24}$";

    public AtgBusSecretKey(String keyId, String secretKey) {
        Asserts.notNull(keyId, "秘钥KEY为空！");
        Asserts.notNull(secretKey, "秘钥SECRET为空！");
        Asserts.isTrue(keyId.matches(KEY_REGEX), AtgBusErrorCode.KEY_ERROR);
        Asserts.isTrue(secretKey.matches(SECRET_REGEX), AtgBusErrorCode.SECRET_ERROR);

        this.keyId = keyId;
        this.secretKey = secretKey;
    }

    /**
     * Getter method for property <tt>keyId</tt>.
     *
     * @return property value of keyId
     */
    public String getKeyId() {
        return keyId;
    }

    /**
     * Setter method for property <tt>keyId</tt>.
     *
     * @param keyId value to be assigned to property keyId
     */
    public void setKeyId(String keyId) {
        this.keyId = keyId;
    }

    /**
     * Getter method for property <tt>secretKey</tt>.
     *
     * @return property value of secretKey
     */
    public String getSecretKey() {
        return secretKey;
    }

    /**
     * Setter method for property <tt>secretKey</tt>.
     *
     * @param secretKey value to be assigned to property secretKey
     */
    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("AtgBusSecretKey{");
        sb.append("keyId='").append(keyId).append('\'');
        sb.append(", secretKey='").append(secretKey).append('\'');
        sb.append('}');
        return sb.toString();
    }
}